import org.testng.annotations.Test;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 * @author 35326
 * 2021/4/2 21:36
 * JDBC测试程序
 */
public class JDBCTest {
	public static void main(String[] args) {
		Driver driver =null;
		try {
			driver = new com.mysql.cj.jdbc.Driver();
		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}
		String url = "jdbc:mysql://localhost:3306/myemployees?serverTimezone=UTC";
		Properties properties = new Properties();
		properties.setProperty("user","root");
		properties.setProperty("password","root");

		try {
			Connection connection = driver.connect(url,properties);
			System.out.println(connection);
		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}
	}

	@Test
	public void test(){
		Driver driver = null;
		try {
			 driver = new com.mysql.cj.jdbc.Driver() ;

		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}
		try {
			DriverManager.registerDriver(driver);
		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}
		try {
			Connection connection = DriverManager.getConnection("jdbc:mysql:///myemployees?serverTimezone=UTC", "root", "root");
			System.out.println(connection);

		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}


	}
}
